#set(title="会员登录 - "+param("AUTH_ERP_NAME"))
#@LayuiLayout()
#define css()
  <link href="#(res_path)/layui/extend/login.css" rel="stylesheet" />
  <link href="#(res_path)/layui/extend/animate.min.css" rel="stylesheet" />
#end
#define content()
<div style="position: relative;height: 100%">
	<div class="elight-product-box animated fadeInUp">
		<h2>#(param("AUTH_ERP_NAME"))</h2>
		<p>#(param("AUTH_ERP_DESC"))</p>
  	<ul class="product-desc">
    </ul>
	</div>
  <div class="elight-login-box animated fadeInRight">
  	<div class="elight-login-header">会员登录</div>
    <div class="elight-login-body">
	    <form class="layui-form">
	    	<div class="layui-form-item">
	      	<label class="login-icon"><i class="layui-icon">&#xe612;</i></label>
	        <input type="text" name="username" lay-verify="required" autocomplete="off" placeholder="用户名/邮箱/手机号" class="layui-input">
	      </div>
	      <div class="layui-form-item">
	      	<label class="login-icon">
	        	<i class="layui-icon">&#xe642;</i>
	        </label>
	        <input type="password" name="password" lay-verify="required" autocomplete="off" placeholder="登陆密码" class="layui-input">
	      </div>
	      <div class="layui-form-item verifyCodeBox" style="display: none;">
	     		<div class="login-code-box">
	        	<label class="login-icon"><i class="layui-icon">&#xe62d;</i></label>
	          <input type="text" name="captcha" autocomplete="off" placeholder="验证码" class="layui-input">
	          <img id="verifyCode" src="../captcha" title="点击更换验证码">
	        </div>
	     	</div>
	      <div class="layui-form-item">
	      	<button class="layui-btn btn-submit" lay-submit lay-filter="login">立即登录</button>
	      </div>
	      <div style="color: #333;font-size: 12px">
	      
	      </div>
	    </form>
    </div>
    <div class="elight-login-fooder"></div>
  </div>
</div>
#end
#define jsFunction()
<script type="text/javascript">
layui.use(['layer', 'form'], function () {
  	var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    form.on('submit(login)', function (data) {
    	$(".btn-submit").html("正在登录...");
      $(".btn-submit").attr('disabled', true).addClass('layui-disabled');
      $.ajax({
      	url: "doLogin",
        data: data.field,
        type: "POST",
        dataType: "json",
        success: function (data) {
        	if (data.result=="success") {
           	$(".btn-submit").html("登录成功，跳转中...");
          	window.location.href = "../index";
          } else {
						if(data.message=="密码错误，请输入验证码重试！"||data.message=="验证码不正确！"){
							$(".verifyCodeBox").show();
							$("#verifyCode").trigger('click');
						}
          	$(".btn-submit").html("立即登录");
            $(".btn-submit").attr('disabled', false).removeClass('layui-disabled');
            $("#verifyCode").trigger('click');
           	layer.alert(data.message,{icon:2});
          }
        }
      });
      return false;
    });
    $("#verifyCode").click(function () {
    	$(this).attr("src", "captcha?r=" + Math.random());
    });
	});
</script>
#end
